<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HLS Video Player</title>
</head>
<body>
<h1>HLS Video Player</h1>
<video id="videoElement" controls width="600" height="400"></video>

<!-- 引入 HLS.js -->
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>

<script>
    document.addEventListener('DOMContentLoaded', function () {
        var videoElement = document.getElementById('videoElement');
        var videoSrc = 'http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8';  // 替换为你的 HLS 视频路径

        if (Hls.isSupported()) {
            var hls = new Hls();
            hls.loadSource(videoSrc);
            hls.attachMedia(videoElement);
            hls.on(Hls.Events.MANIFEST_PARSED, function () {
                videoElement.play();
            });
        } else if (videoElement.canPlayType('application/vnd.apple.mpegurl')) {
            videoElement.src = videoSrc;
            videoElement.addEventListener('loadedmetadata', function () {
                videoElement.play();
            });
        } else {
            console.error('HLS is not supported in this browser.');
        }
    });
</script>
</body>
</html>
